// ignore_for_file: file_names, must_be_immutable, constant_identifier_names, slash_for_doc_comments, avoid_unnecessary_containers, prefer_const_constructors, unnecessary_cast, sized_box_for_whitespace, prefer_function_declarations_over_variables, overridden_fields, annotate_overrides, prefer_const_literals_to_create_immutables, unnecessary_null_comparison, deprecated_member_use


import 'package:flutter/material.dart';
import 'package:mybase/base/tool/empty/FFEmpty.dart';

class YCGlobalManger {
  // 单例公开访问点
  factory YCGlobalManger() => _sharedInstance();

  // 静态、同步、私有访问点
  static YCGlobalManger _sharedInstance() {
    return _instance;
  }

  // 静态私有成员，没有初始化
  static final YCGlobalManger _instance = YCGlobalManger._();

  // 私有构造函数
  YCGlobalManger._() {
    // 具体初始化代码

  }

  init(){
    //全局忽略UI异常
    FlutterError.onError = (FlutterErrorDetails details) {
      if (FFEmpty.stringIsEmpty(details.library)) {
        print('YCGlobalManger error = ${details.library} , main catch a exception ${details.exception.toString()}');
        return;
      }

      //忽略UI沉浸异常
      if (details.library?.endsWith("library") == true) {
        print('YCGlobalManger error = ${details.library} , main catch a exception ${details.exception.toString()}');
        return;
      }

      if (details.library?.startsWith("image") == true) {
        print('YCGlobalManger error = ${details.library} , main catch a exception ${details.exception.toString()}');
        return;
      }

      if (details.library?.startsWith("SVG") == true) {
        print('YCGlobalManger error = ${details.library} , main catch a exception ${details.exception.toString()}');
        return;
      }


      //上报并打印
      print('YCGlobalManger 出错并上报错误 = ${details.library} , main catch a exception ${details.exception.toString()}');
      FlutterError.dumpErrorToConsole(details);
    };
  }
  
  
}
